﻿<Window x:Class="MsbuildLauncher.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MsbuildLauncher"
        Title="{Binding WindowTitle}" Height="600" Width="800"
        Loaded="Window_Loaded"
        Closed="Window_Closed"
        AllowDrop="true"
        Drop="Window_Drop"
        Icon="Images/MSBuildLauncherIcon.ico">
    
    <Window.Resources>
        <local:BooleanNotConverter x:Key="BooleanNotConverter" />
    </Window.Resources>
    
    <DockPanel>
        <DockPanel DockPanel.Dock="Top">
            <StackPanel>
                <StackPanel Orientation="Horizontal" Background="{StaticResource WindowBackgroundBrush}">
                    <StackPanel.Resources>
                        <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
                            <Setter Property="MinWidth" Value="60" />
                            <Setter Property="MinHeight" Value="30" />
                        </Style>
                    </StackPanel.Resources>

                    <Button Name="buttonOpen" Click="buttonOpen_Click" IsEnabled="{Binding IsBuildInProgress, Converter={StaticResource BooleanNotConverter}}">Open</Button>
                    <Button Name="buttonReload" Click="buttonReload_Click" IsEnabled="{Binding IsBuildInProgress, Converter={StaticResource BooleanNotConverter}}">Reload</Button>
                    <Button Name="buttonEdit" Click="buttonEdit_OnClick" Content="Edit" ToolTip="Open the MSBuild file with a program (associated with .xml)"/>
                    
                    <Separator />

                    <Button Name="buttonBuild"
                            ToolTip="Build default target(s)"
                            Click="buttonBuild_Click"
                            IsEnabled="{Binding IsBuildInProgress, Converter={StaticResource BooleanNotConverter}}">Build</Button>
                    <Button Name="buttonCancel" Click="buttonCancel_Click" IsEnabled="{Binding IsBuildInProgress}">Cancel</Button>
                    
                    <Separator />
                    <Button Name="buttonAdmin"
                            ToolTip="Run MSBuild Launcher with the administrator privilledge"
                            Click="ButtonAdmin_Click"
                            IsEnabled="{Binding IsAdmin, Converter={StaticResource BooleanNotConverter}}">Admin</Button>

                    <Separator />
                    <Button Name="buttonSetting" Click="buttonSetting_Click" Content="Settings" />
                </StackPanel>

                <DockPanel Background="{StaticResource WindowBackgroundBrush}">
                    <TextBlock DockPanel.Dock="Left" Margin="4,0,4,0" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{StaticResource TextBrush}">File:</TextBlock>
                    <ComboBox Name="comboBoxFilePath" SelectionChanged="comboBoxFilePath_SelectionChanged" ItemsSource="{Binding HistoryPathList}" SelectedValue="{Binding SelectedXmlPath}"></ComboBox>
                </DockPanel>
            </StackPanel>
        </DockPanel>
        
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Name="columnDefinitionTarget" Width="150" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Name="columnDefinitionProperty" Width="200" />
            </Grid.ColumnDefinitions>

            <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" 
                          Background="{StaticResource ControlBackgroundBrush}">
                <Expander Header="Targets" Background="{StaticResource WindowBackgroundBrush}" IsExpanded="True" IsEnabled="{Binding IsBuildInProgress, Converter={StaticResource BooleanNotConverter}}">
                    <ItemsControl ItemsSource="{Binding TargetItemList}" >
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>

                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Button Click="buttonTarget_Click"
                                        MinHeight="20"
                                        Margin="4"
                                        Padding="10,0,0,0"
                                        HorizontalContentAlignment="Left">
                                    <TextBlock Text="{Binding Name}">
                                        <TextBlock.Style>
                                            <Style TargetType="TextBlock">
                                                <Setter Property="Foreground" Value="White" />
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding IsLastExecuted}" Value="True">
                                                        <Setter Property="Foreground" Value="Yellow" />
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </TextBlock.Style>    
                                    </TextBlock>
                                </Button>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Expander>
            </ScrollViewer>

            <GridSplitter Grid.Column="0" Width="2" HorizontalAlignment="Right" Background="{StaticResource NormalBorderBrush}"/>

            <RichTextBox Name="richTextBoxLog" VerticalScrollBarVisibility="Visible" IsReadOnly="True" Grid.Column="1" FontSize="{Binding FontSize}" FontFamily="{Binding FontName}">
            </RichTextBox>

            <GridSplitter Grid.Column="1" Width="2" HorizontalAlignment="Right" Background="{StaticResource NormalBorderBrush}"/>

            <ScrollViewer Name="scrollViewerProperties"
                HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"
                Background="{StaticResource ControlBackgroundBrush}" Grid.Column="2"
                SizeChanged="scrollViewerProperties_SizeChanged">
                <StackPanel Background="{StaticResource WindowBackgroundBrush}">
                    <Expander Name="expanderCommonProperties" Header="Common Properties" IsExpanded="True">
                        <local:PropertiesControl x:Name="propertiesControlCommon" DataContext="{Binding CommonPropertyList}" />
                    </Expander>

                    <Expander Name="expanderFileProperties" Header="File Properties" IsExpanded="True">
                        <local:PropertiesControl x:Name="propertiesControlFile" DataContext="{Binding FilePropertyList}" />
                    </Expander>
                </StackPanel>
            </ScrollViewer>
        </Grid>
        
    </DockPanel>
</Window>
